using System;
using System.ComponentModel;
using System.Transactions;

using SIS.ENT;
using SIS.DAL;


namespace SIS.BLL
{

    /// <summary>
    /// The StudentLastSchoolHistoryTableManager class is responsible for managing BO.StudentLastSchoolHistoryTable objects in the system.
    /// </summary>
    [DataObjectAttribute()]
    public class StudentLastSchoolHistoryTableManager
    {

        #region "Public Methods"

        /// <summary>
        /// Gets a list with all StudentLastSchoolHistoryTable objects in the database.
        /// </summary>
        /// <returns>A list with all StudentLastSchoolHistoryTable from the database when the database contains any, or null otherwise.</returns>
        [DataObjectMethod(DataObjectMethodType.Select, true)]
        public static StudentLastSchoolHistoryTableList GetList()
        {
            return StudentLastSchoolHistoryTableDB.GetList();
        }

        /// <summary>
        /// Gets a single StudentLastSchoolHistoryTable from the database without its data.
        /// </summary>
        /// <param name="userAccountKey">The UserAccountKey of the StudentLastSchoolHistoryTable in the database.</param>
        /// <returns>A StudentLastSchoolHistoryTable object when the UserAccountKey exists in the database, or <see langword="null"/> otherwise.</returns>
        [DataObjectMethod(DataObjectMethodType.Select, false)]
        public static StudentLastSchoolHistoryTable GetItem(int SLSHKey, int userAccountKey)
        {
            return GetItem(SLSHKey, userAccountKey, false);
        }

        /// <summary>
        /// Gets a single StudentLastSchoolHistoryTable from the database.
        /// </summary>
        /// <param name="userAccountKey">The UserAccountKey of the StudentLastSchoolHistoryTable in the database.</param>
        /// <param name="getStudentLastSchoolHistoryTableRecords">Determines whether to load all associated StudentLastSchoolHistoryTable records as well.</param>
        /// <returns>
        /// A StudentLastSchoolHistoryTable object when the UserAccountKey exists in the database, or <see langword="null"/> otherwise.
        /// </returns>
        [DataObjectMethod(DataObjectMethodType.Select, false)]
        public static StudentLastSchoolHistoryTable GetItem(int SLSHKey, int userAccountKey, bool getStudentLastSchoolHistoryTableRecords)
        {
            StudentLastSchoolHistoryTable myStudentLastSchoolHistoryTable = StudentLastSchoolHistoryTableDB.GetItem(SLSHKey, userAccountKey);
            return myStudentLastSchoolHistoryTable;
        }

        /// <summary>
        /// Saves a StudentLastSchoolHistoryTable in the database.
        /// </summary>
        /// <param name="myStudentLastSchoolHistoryTable">The StudentLastSchoolHistoryTable instance to save.</param>
        /// <returns>The new UserAccountKey if the StudentLastSchoolHistoryTable is new in the database or the existing UserAccountKey when an item was updated.</returns>
        [DataObjectMethod(DataObjectMethodType.Update, true)]
        public static int Save(StudentLastSchoolHistoryTable myStudentLastSchoolHistoryTable)
        {
            using (TransactionScope myTransactionScope = new TransactionScope())
            {
                int studentLastSchoolHistoryTableUserAccountKey = StudentLastSchoolHistoryTableDB.Save(myStudentLastSchoolHistoryTable);

                //  Assign the StudentLastSchoolHistoryTable its new (or existing UserAccountKey).
                myStudentLastSchoolHistoryTable.UserAccountKey = studentLastSchoolHistoryTableUserAccountKey;

                myTransactionScope.Complete();

                return studentLastSchoolHistoryTableUserAccountKey;
            }
        }

        /// <summary>
        /// Deletes a StudentLastSchoolHistoryTable from the database.
        /// </summary>
        /// <param name="myStudentLastSchoolHistoryTable">The StudentLastSchoolHistoryTable instance to delete.</param>
        /// <returns>Returns true when the object was deleted successfully, or false otherwise.</returns>
        [DataObjectMethod(DataObjectMethodType.Delete, true)]
        public static bool Delete(StudentLastSchoolHistoryTable myStudentLastSchoolHistoryTable)
        {
            return StudentLastSchoolHistoryTableDB.Delete(myStudentLastSchoolHistoryTable.UserAccountKey);
        }

        #endregion

    }

}
